<?php
/**
 * Single Product tabs
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.0.0
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/**
 * Filter tabs and allow third parties to add their own
 *
 * Each tab is an array containing title, callback and priority.
 * @see woocommerce_default_product_tabs()
 */
$tabs = apply_filters( 'woocommerce_product_tabs', array() );

if ( ! empty( $tabs ) ) : ?>

	<div class="woocommerce-tabs" style="margin-bottom:30px;border-bottom:#cccccc 1px solid;padding-bottom:30px;">

		<?php if (! has_term(array('Solar Hot Water Installation Training'), 'product_cat')) { ?>

		<ul class="tabs">
			<?php foreach ( $tabs as $key => $tab ) : ?>

				<li class="<?php echo $key ?>_tab">
					<a href="#tab-<?php echo $key ?>"><?php echo apply_filters( 'woocommerce_product_' . $key . '_tab_title', $tab['title'], $key ) ?></a>
				</li>

			<?php endforeach; ?>
            
            	<!-- BEGIN CUSTOM PRODUCT PAGE TAB ADDITIONS -->
                	<li class="documents_tab"><a href="#tab-documents">Documents</a></li>
                    <li class="videos_tab"><a href="#tab-videos">Videos</a></li>
                    <li class="faqs_tab"><a href="#tab-faqs">FAQs</a></li>
                    <li class="resources_tab"><a href="#tab-resources">Resources</a></li>
                <!-- END CUSTOM PRODUCT PAGE TAB ADDITIONS -->
		</ul>
		<?php foreach ( $tabs as $key => $tab ) : ?>

			<div class="panel entry-content" id="tab-<?php echo $key ?>">
				<?php call_user_func( $tab['callback'], $key, $tab ) ?>
			</div>

		<?php endforeach; ?>
        
        	<!-- BEGIN CUSTOM PRODUCT PAGE TAB CONTENT AREA -->
            	<div class="panel entry-content" id="tab-documents">
                	<h2>Related Documents</h2>
                    <?php // Custom Query For Documents Related To This Product - Display In List
						$args = array(
	'post_type' => 'document',
	'tax_query' => array(
		array(
			'taxonomy' => 'wpdr-file-tags',
			'field' => 'slug',
			'terms' => ''.get_the_ID().''
		)
	)
);
$productdocs = new WP_Query( $args );
						echo '<ul>';
						if($productdocs->have_posts()) { ?>
							<?php while($productdocs->have_posts()) : 
								$productdocs->the_post(); ?>
                        
                                <li><a href="<?php the_permalink(); ?>" target="_blank" title="Download <?php the_field('documenttype'); ?>"><?php the_field('documenttype'); ?> - <?php the_title(); ?></a></li>
                        
                            <?php endwhile; ?>
                        <?php } else { ?>
                        	<li>There Are No Documents To Display</li>
                        <?php } wp_reset_query(); ?>
                    	</ul>
                </div>
                <div class="panel entry-content" id="tab-videos">
                	<h2>Related Videos</h2>
                </div>
                <div class="panel entry-content" id="tab-faqs">
                	<h2>Related FAQs &amp; Technical Tips</h2>
                    <?php // Custom Query For Technical Tips (FAQs) Related To This Product - Display In List
						$productfaqs = new WP_Query(array('cat' => '4', 'posts_per_page' => '-1', 'tag' => ''.get_the_ID().''));
						echo '<ul>';
						if($productfaqs->have_posts()) { ?>
							<?php while($productfaqs->have_posts()) : 
								$productfaqs->the_post(); ?>
                                <li><a href="<?php the_permalink(); ?>" target="_blank" rel="shadowbox"><?php the_title(); ?></a></li>
                            <?php endwhile; ?>
                        <?php } else { ?>
                        	<li>There Are No Technical Tips To Display</li>
                        <?php } wp_reset_query(); ?>
                    	</ul>
                </div>
                <div class="panel entry-content" id="tab-resources">
                	<h2>Additional Related Resources</h2>
                    <?php // Custom Query For Press Releases Related To This Product - Display In List
						echo '<h3>Product Press Releases</h3>';

							$args = array(
								'post_type' => 'post',
								'showposts' => -1,
								'tag' => ''.get_the_ID().'',
								'category__in' => array(11)
							);
							
						$productpr = new WP_Query($args);
						echo '<ul>';
						if($productpr->have_posts()) { ?>
							<?php while($productpr->have_posts()) : 
								$productpr->the_post(); ?>
                                <li><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title(); ?></a></li>
                            <?php endwhile; ?>
                        <?php } else { ?>
                        	<li>There Are No Press Releases To Display</li>
						<?php } wp_reset_query(); ?>
                        
                    	</ul>
                        
                    <?php // Custom Query For Reference Projects Related To This Product - Display In List
						echo '<h3>Product Featured Projects</h3>';

						// REFERENCE PROJECTS
							$args = array(
								'post_type' => 'post',
								'showposts' => -1,
								'tag' => ''.get_the_ID().'',
								'category__in' => array(111, 112, 113, 114)
							);

						$productprojects = new WP_Query($args);
						echo '<ul>';
						if($productprojects->have_posts()) { ?>
							<?php while($productprojects->have_posts()) : 
								$productprojects->the_post(); ?>
                                <li><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title(); ?></a></li>
                            <?php endwhile; ?>
                        <?php } else { ?>
                        	<li>There Are No Featured Projects To Display</li>
                        <?php } wp_reset_query(); ?>
                    	</ul>
                </div>
            <!-- END CUSTOM PRODUCT PAGE TAB CONTENT AREA -->

		<?php } else { ?>

			<ul class="tabs">
				<li class="dets_tab"><a href="#tab-dets">Course Details</a></li>
				<li class="faqs_tab"><a href="#tab-faqs">FAQs</a></li>
				<li class="docs_tab"><a href="#tab-docs">Related Documents &amp; Guides</a></li>
			</ul>

			<div class="panel entry-content" id="tab-dets">
				<div style="width:660px;float:left;margin:0px;margin-right:40px;">
					<h2>Course Details</h2>
					<table cellpadding="0" cellspacing="0" style="width:658px;border:#cccccc 1px solid;">
						<tr>
							<th style="text-align:left;height:30px;line-height:30px;background:#f2f2f2;font-weight:bold;padding-left:10px;">Month</th>
							<th style="text-align:center;height:30px;line-height:30px;background:#f2f2f2;font-weight:bold;">Dates</th>
							<th style="text-align:center;height:30px;line-height:30px;background:#f2f2f2;font-weight:bold;">Location</th>
							<th style="text-align:center;height:30px;line-height:30px;background:#f2f2f2;font-weight:bold;">Levels</th>
							<th style="text-align:right;height:30px;line-height:30px;background:#f2f2f2;font-weight:bold;padding-right:10px;">Instructor</th>
						</tr>
						<tr>
							<td style="text-align:left;height:30px;line-height:30px;padding-left:10px;"><?php the_field('training_month'); ?></td>
							<td style="text-align:center;height:30px;line-height:30px;"><?php the_field('training_dates'); ?></td>
							<td style="text-align:center;height:30px;line-height:30px;"><?php the_field('training_location'); ?></td>
							<td style="text-align:center;height:30px;line-height:30px;"><?php the_field('training_levels'); ?></td>
							<td style="text-align:right;height:30px;line-height:30px;padding-right:10px;"><?php the_field('training_instructor'); ?></td>
						</tr>
					</table>

					<h2>Training Venue</h2>
					<?php if(get_field('training_location') == 'Binghamton, NY') { ?>
						<p>
							<strong>SunMaxx Training Center</strong><br />
							56 Broome Corporate Dr<br />
							Conklin, NY 13748
						</p>
					<?php } else { ?>
						<p>
							<strong>TBD</strong>
						</p>
					<?php } ?>

					<h2>Course Overview</h2>
					<div style="width:660px;float:left;margin:0px;margin-bottom:20px;">
						<img src="http://www.sunmaxxsolar.com/wp-content/uploads/2013/07/level-1-solar-thermal-training.jpg" alt="Level 1 Solar Thermal Training" style="width:150px;float:left;margin:0px;margin-right:20px;" />
						<h3 style="font-size:15px;color:#e77d1d;clear:none;margin-bottom:10px;">Level 1: Intro To Solar Thermal Systems</h3>
						<p>Let SunMaxx Solar give you a leg up over the competition, and prepare you for your hands-on training with our introduction to solar thermal systems and installation. In this workshop, you will get the basics you need to move forward as a professional solar thermal installer.</p>
						<div style="width:100%;height:0px;clear:both;"></div>
					</div>
					<div style="width:660px;float:left;margin:0px;margin-bottom:20px;">
						<img src="http://www.sunmaxxsolar.com/wp-content/uploads/2013/07/level-2-solar-thermal-training.jpg" alt="Level 2-3 Solar Thermal Training" style="width:150px;float:left;margin:0px;margin-right:20px;" />
						<h3 style="font-size:15px;color:#e77d1d;clear:none;margin-bottom:10px;">Level 2 &amp; 3: Hands-On Installations</h3>
						<p>A completely hands-on course in solar domestic hot water system sizing, design and installation. Put your new-found solar thermal knowledge to good use assembling and installing SunMaxx Solar's industry-leading solar thermal collectors and systems.</p>
						<div style="width:100%;height:0px;clear:both;"></div>
					</div>

					<?php  if(get_field('training_levels') == '1 - 5') { // LEVELS 1-3 DESCRIPTIONS ?>
						<div style="width:660px;float:left;margin:0px;margin-bottom:20px;">
							<img src="http://www.sunmaxxsolar.com/wp-content/uploads/2013/07/level-4-solar-thermal-training.jpg" alt="Level 4 Solar Thermal Training" style="width:150px;float:left;margin:0px;margin-right:20px;" />
							<h3 style="font-size:15px;color:#e77d1d;clear:none;margin-bottom:10px;">Level 4: Solar Thermal Sales &amp; Marketing</h3>
							<p>The heart of your solar business is the ability to go out and get lot of new clients. Let SunMaxx Solar's sales and marketing experts walk you through today's cutting-edge, high-impact sales and marketing tools, strategies and secrets, applied directly to the solar market!</p>
							<div style="width:100%;height:0px;clear:both;"></div>
						</div>
						<div style="width:660px;float:left;margin:0px;margin-bottom:20px;">
							<img src="http://www.sunmaxxsolar.com/wp-content/uploads/2013/07/level-5-solar-thermal-training.jpg" alt="Level 5 Solar Thermal Training" style="width:150px;float:left;margin:0px;margin-right:20px;" />
							<h3 style="font-size:15px;color:#e77d1d;clear:none;margin-bottom:10px;">Level 5: Commercial Solar Thermal Sales</h3>
							<p>Get ready to tackle the industry's biggest, most lucrative projects. Our Commercial Solar Thermal Sales workshop will train you in the process, tools and strategies for attracting and selling small and large commercial solar thermal customers in your market.</p>
							<div style="width:100%;height:0px;clear:both;"></div>
						</div>
					<?php } ?>

				</div>
				<div style="width:300px;float:left;margin:0px;">
					<img src="http://www.sunmaxxsolar.com/wp-content/uploads/2013/07/solar-thermal-training-all-binders.jpg" alt="<?php the_title(); ?>" style="width:300px;margin-bottom:30px;" />
					<img src="http://www.sunmaxxsolar.com/wp-content/gallery/training-seminar/sunmaxx-solar-training-seminar-04.jpg" alt="SunMaxx Solar Thermal Training" style="width:300px;margin-bottom:0px;" />
					<?php  if(get_field('training_levels') == '1 - 5') { // LEVELS 1-3 DESCRIPTIONS ?>
						<img src="http://www.sunmaxxsolar.com/wp-content/gallery/training-seminar/sunmaxx-solar-training-seminar-126.jpg" alt="SunMaxx Solar Thermal Training" style="width:300px;margin-bottom:0px;" />
						<img src="http://www.sunmaxxsolar.com/wp-content/gallery/training-seminar/sunmaxx-solar-training-seminar-78.jpg" alt="SunMaxx Solar Thermal Training" style="width:300px;margin-bottom:0px;" />
					<?php } ?>
				</div>
			</div>

			<div class="panel entry-content" id="tab-faqs">
				<h2>Frequently Asked Questions</h2>
				<ul style="padding-left:10px;margin-left:10px;">
					<?php // QUERY FAQs
						$args = array(
							'post_type' => 'post',
							'tag' => 'rel_training',
							'category__in' => array(4)
						);

						$trainingfaqs = new wp_query($args);
						while($trainingfaqs->have_posts()) : $trainingfaqs->the_post();
					?>
            					<li><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title(); ?></a></li>
            				<?php
						endwhile;
						wp_reset_query();
					?>
            			</ul>
			</div>

			<div class="panel entry-content" id="tab-docs">
				<h2>Related Documents &amp; Guides</h2>
				<ul style="padding-left:10px;margin-left:10px;">
				<?php // Query Related Product Documents
					$args = array(
						'post_type' => 'document',
						'tax_query' => array(
							array(
								'taxonomy' => 'wpdr-file-tags',
								'field' => 'slug',
								'terms' => 'rel_training'
							)
						)
					);

					$trainingdocs = new wp_query($args);
					while($trainingdocs->have_posts()) : $trainingdocs->the_post();
				?>
                			<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
                		<?php
					endwhile;
					wp_reset_query();
				?>
				</ul>
			</div>

		<?php } ?>

		<div style="width:100%;height:0px;clear:both;"></div>
            
	</div>

<?php endif; ?>